package com.triones.ljr.controller.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.triones.ljr.entity.dto.EnterpriseDO;
import com.triones.ljr.entity.vo.SsEnterpriseVO;
import com.triones.ljr.service.EnterpriseService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * api - 企业管理
 *
 * @Author: triones
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/enterprise")
public class ApiEnterpriseController extends BaseController {

    private final EnterpriseService enterpriseService;

    /**
     * 企业注册
     * @param dto
     * @return
     */
    @PostMapping("/register")
    public R<Void> register(@Validated @RequestBody EnterpriseDO dto) {
        return toAjax(enterpriseService.register(dto));
    }

    /**
     * 检查是否需要提交企业注册 true:需要、false:不需要
     * @return
     */
    @GetMapping("/checkIsRegister")
    public R<Boolean> checkIsRegister() {
        return R.ok("操作成功",enterpriseService.checkIsRegister());
    }

    /**
     * 企业列表
     * @return
     */
    @GetMapping("/list")
    public R<List<SsEnterpriseVO>> getEnterpriseList(String keyword) {
        return R.ok("操作成功",enterpriseService.getEnterpriseList(keyword));
    }
}
